const SpeakModel = require("../models/SpeaksModel")



const SpeakService = {
    add_speak: async (data) => {
        return await SpeakModel.create({
            ...data
        })
    },
    get_lsit: async (id = 0) => {
        return {
            data: await SpeakModel.find().limit(8).skip(id).select("-__v").sort({ publish_time: "desc" }),
            count: await SpeakModel.countDocuments()
        }
    },
    one_put: async (data) => {
        return await SpeakModel.updateOne({
            _id: data._id
        }, {
            ...data
        })
    },
    one_delete: async (id) => {
        return await SpeakModel.deleteOne({
            _id: id
        })
    }
}
module.exports = SpeakService


